﻿using System;
using System.Text;

namespace Fine.Utils.Functions
{
    /// <summary>
    /// Character functions.
    /// </summary>
    public static class CharExt
    {

        public static string Replicate(this char c, int count)
        {
            if (count < 0)
                throw new ArgumentException("Count of character ({0}) could not be negative ({1})".With(c, count), "count");

            switch (count)
            {
                case 0:
                    return string.Empty;
                case 1:
                    return c.ToString();
                default:
                    StringBuilder buf = new StringBuilder(count);
                    for (int i = count; i > 0; i--)
                        buf.Append(c);
                    return buf.ToString();
            }
        }


    }
}
